package algorithm.graph;

/**
 * 带权值的边类
 */
public class Edge implements Comparable<Edge> {
    public int start;//边的起点序号
    public int dest;//边的终点序号
    public int weight;//边的权值

    public Edge(int start,int dest, int weight) {
        this.start = start;
        this.dest = dest;
        this.weight = weight;
    }

    @Override
    public String toString() {
        return "Edge{" +
                "start=" + start +
                ", dest=" + dest +
                ", weight=" + weight +
                '}';
    }

    /**
     * 约定两条边比较大小的规则
     * @param e
     * @return
     */
    public int compareTo(Edge e) {
        if (this.start != e.start)
            return this.start-e.start;
        else
            return this.dest - e.dest;
    }
}
